package com.xoa.controller.hr.socialRelations;

import com.xoa.model.common.HrCode;
import com.xoa.model.hr.socialRelations.SocialRelationsWithBLOBs;
import com.xoa.service.hr.socialRelations.SocialRelationsService;
import com.xoa.util.ToJson;
import com.xoa.util.common.wrapper.BaseWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @program: xoa
 * @description: 社会关系
 * @author: xiaomeng.Yu
 * @create: 2018-07-09 15:24
 **/

@Controller
@RequestMapping("/hr/manage")
public class SocialRelationsController {

    @Autowired
    SocialRelationsService socialRelationsService;


    /**
    * @Description:导航栏
    * @Author: xiaomeng.Yu
    * @Date: 2018/7/9
    */
    @RequestMapping("/staff_relatives")
    public String navigationBar(){
        return "app/hr/socialRelations/navigationBar";
    }

    /**
     * @Description:转跳社会关系管理页面
     * @Author: xiaomeng.Yu
     * @Date: 2018/7/9
     */
    @RequestMapping("socialRelationsManaer")
    public String socialRelationsManaer(){
        return "/app/hr/socialRelations/SocialRelationsManaer";
    }

    /**
     * @Description:转跳新建社会关系页面
     * @Author: xiaomeng.Yu
     * @Date: 2018/7/9
     */
    @RequestMapping("/newSocialRelations")
    public String newSocialRelations(){
        return "/app/hr/socialRelations/NewSocialRelations";
    }

    /**
     * @Description:转跳修改社会关系页面
     * @Author: xiaomeng.Yu
     * @Date: 2018/7/9
     */
    @RequestMapping("/socialRelationUpdate")
    public String socialRelationUpdate(){
        return "/app/hr/socialRelations/UpdateSocialRelations";
    }

    /**
     * @Description:转跳社会关系信息导入页面
     * @Author: xiaomeng.Yu
     * @Date: 2018/7/9
     */
    @RequestMapping("/socialRelationsImport")
    public String socialRelationsImport(){
        return "/app/hr/socialRelations/SocialRelationsImport";
    }

    /**
     * @Description:转跳社会关系查询页面
     * @Author: xiaomeng.Yu
     * @Date: 2018/7/9
     */
    @RequestMapping("/socialRelationsQuery")
    public String socialRelationsQuery(){
        return "/app/hr/socialRelations/SocialRelationsQuery";
    }

    /**
    * @Description: 转跳社会关系详情页
    * @Author: xiaomeng.Yu
    * @Date: 2018/7/10
    */
    @RequestMapping("/socialRelationsDetail")
    public String socialRelationsDetail(){
        return "/app/hr/socialRelations/SocialRelationsDetail";
    }

    //功能
    /**
     * @Description: 保存
     * @Param: []
     * @return: com.xoa.util.common.wrapper.BaseWrapper
     * @Author: xiaomeng.Yu
     * @Date: 2018/7/9
     */
    @ResponseBody
    @RequestMapping("/saveSocialRelations")
    public BaseWrapper saveSocialRelations(SocialRelationsWithBLOBs socialRelation){
       return socialRelationsService.saveSocialRelation(socialRelation);
    }

    /**
     * @Description: 查询
     * @Param: []
     * @return: com.xoa.util.common.wrapper.BaseWrapper
     * @Author: xiaomeng.Yu
     * @Date: 2018/7/9
     */
    @ResponseBody
    @RequestMapping("/getSocialRelations")
    public BaseWrapper getSocialRelations(HttpServletRequest request,Integer page,Integer pageSize,boolean useFlag,String staffRole){
        return socialRelationsService.getSociaRelation(request,page,pageSize,useFlag,staffRole);
    }

    /** 
    * @Description: 社会关系详情 
    * @Param: [] 
    * @return: com.xoa.util.common.wrapper.BaseWrapper 
    * @Author: xiaomeng.Yu
    * @Date: 2018/7/10 
    */ 
    @ResponseBody
    @RequestMapping("/getSocialRelationsById")
    public BaseWrapper getSocialRelationsById(HttpServletRequest request,Integer socialRelId){
        return socialRelationsService.getSociaRelationById(request,socialRelId);
    }

    /** 
    * @Description: 根据条件查询
    * @Param: [socialRelId] 
    * @return: com.xoa.util.common.wrapper.BaseWrapper 
    * @Author: xiaomeng.Yu
    * @Date: 2018/7/10 
    */ 
    @ResponseBody
    @RequestMapping("/getSocialRelationsByIdList")
    public BaseWrapper getSocialRelationsByIdList(HttpServletRequest request,Integer page,Integer pageSize,boolean useFlag,SocialRelationsWithBLOBs socialRelId){
        return socialRelationsService.getSociaRelationByIdList(request,page,pageSize,useFlag,socialRelId);
    }

    /** 
    * @Description: 修改
    * @Param: [socialRelId] 
    * @return: com.xoa.util.common.wrapper.BaseWrapper 
    * @Author: xiaomeng.Yu
    * @Date: 2018/7/10 
    */ 
    @ResponseBody
    @RequestMapping("/updateSocialRelations")
    public BaseWrapper updateSocialRelations(SocialRelationsWithBLOBs socialRelId){
        return socialRelationsService.updateSociaRelation(socialRelId);
    }

    /**
    * @Description: 删除
    * @Param: [socialRelId]
    * @return: com.xoa.util.common.wrapper.BaseWrapper
    * @Author: xiaomeng.Yu
    * @Date: 2018/7/11
    */
    @RequestMapping("/deleteSocialRelations")
    @ResponseBody
    public BaseWrapper deleteSocialRelations(@RequestParam("socialRelId[]") Integer[] socialRelId){
        return socialRelationsService.deleteSocialRelations(socialRelId);
    }

    /**
    * @Description: 导出
    * @Param: [request, response, socialRelations]
    * @return: void
    * @Author: xiaomeng.Yu
    * @Date: 2018/7/11
    */
    @RequestMapping("/exportSocialRelations")
    @ResponseBody
    public  void exportLearningExperience(HttpServletRequest request, HttpServletResponse response, SocialRelationsWithBLOBs socialRelations){
        socialRelationsService.exportSocialRelations(request,response,socialRelations);
    }

    /**
     * @Description: 导入
     * @Param: [request, response, socialRelations]
     * @return: void
     * @Author: xiaomeng.Yu
     * @Date: 2018/7/11
     */
    @RequestMapping("/importSocialRelations")
    @ResponseBody
    public  BaseWrapper importLearningExperience(MultipartFile file) throws IOException {
       return socialRelationsService.importSocialRelations(file);
    }

    @RequestMapping("/getHrCode")
    @ResponseBody
    public ToJson<HrCode> getHrCodes(String type) {
        return socialRelationsService.getHrCodes(type);
    }
}
